package com.eff.android.lib.ui;

import com.eff.android.lib.R;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;

public class ERowView extends LinearLayout{

	EImageView left;
	EImageView right;
	
	/*
	 * Get image view item in this row
	 * Params:
	 * 	true: return left item
	 * 	false: return right item
	 */
	public EImageView GetImageView(boolean isLeft)
	{
		if(isLeft)
			return left;
		return right;
	}
	
	public ERowView(Context context, AttributeSet attrs) {
		super(context, attrs);
		initViews(context);
	}

	private void initViews(Context context) {
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		inflater.inflate(R.layout.e_row_view, this);
		EImageView l = (EImageView)findViewById(R.id.eImageViewLeft);
		EImageView r = (EImageView)findViewById(R.id.eImageViewRight);
		l.getImg().setImageBitmap(left.getBitmap());
		l.getWordText().setText(left.getWord());
		r.getImg().setImageBitmap(right.getBitmap());
		r.getWordText().setText(right.getWord());
	}
	
	public EImageView getImageViewLeft(){
		return (EImageView)findViewById(R.id.eImageViewLeft);
	}
	
	public EImageView getImageViewRight(){
		return (EImageView)findViewById(R.id.eImageViewRight);
	}
	
	public ERowView(Context context) {
		super(context);
		initViews(context);
	}

	public ERowView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		initViews(context);
	}
	
	public ERowView(Context context, EImageView left, EImageView right){
		super(context);
		this.left = left;
		this.right = right;
		initViews(context);
	}
}
